import {
    FormItemType,
    CommonState,
    DisplaySlide,
    DisplayRuleWay
} from 'assets/js/Constant'

const columns = [{
        title: '编号',
        dataIndex: 'id',
        key: 'id',
        /**
         * title自定义表头： #id
         * customRender自定义表内容：
         *  #id="{ text }"
         *  #id="{text: tags}"
         *  #id="{text, record}"
         */
        slots: {
            title: 'id',
            customRender: 'id'
        },
    },
    {
        title: '资源名称',
        dataIndex: 'permissionName',
        key: 'permissionName',
        slots: {
            // 这里和图标一起展示
            customRender: 'permissionName'
        },
    },
    {
        title: '资源类型',
        dataIndex: 'permissionType',
        key: 'permissionType',
        slots: {
            customRender: 'permissionType'
        }
    },
    {
        title: '资源链接',
        dataIndex: 'permissionLink',
        key: 'permissionLink',
        slots: {
            customRender: 'permissionLink'
        }
    },
    {
        title: '资源组件标识',
        dataIndex: 'permissionKey',
        key: 'permissionKey',
        slots: {
            customRender: 'permissionKey'
        }
    },
    {
        title: '资源状态',
        dataIndex: 'permissionState',
        key: 'permissionState',
        slots: {
            customRender: 'permissionState'
        }
    },
    {
        title: '创建时间',
        dataIndex: 'createTime',
        key: 'createTime',
        slots: {
            customRender: 'createTime'
        }
    },
    {
        title: '操作',
        key: 'action',
        slots: {
            customRender: 'action'
        },
    },
];

const searchFormSchema = {
    options: {
        labelCol: 4,
        wrapperCol: 20,
        layout: 'inline',
    },
    groups: [{
        fields: [{
            type: FormItemType.INPUT, // password textarea number
            label: "资源名称",
            name: "permissionName",
            placeholder: "请输入资源名称"
        }]
    }]
};

const editFormSchema = {
    options: {
        labelCol: 8,
        wrapperCol: 18,
        layout: 'vertical',
    },
    groups: [{
        label: "基本信息",
        grid: 3,
        fields: [{
                type: FormItemType.RADIO,
                label: "资源类型",
                name: "permissionType",
                rules: [{
                    required: true,
                    message: "请选择资源类型"
                }],
                props: {
                    label: "label",
                    value: "value"
                },
                sourceData: [{
                    label: "DIR",
                    value: "DIR"
                }, {
                    label: "MENU",
                    value: "MENU"
                }, {
                    label: "BUTTON",
                    value: "BUTTON"
                }, ],
                style: 'solid',
            }, {
                type: FormItemType.INPUT,
                label: "资源名称",
                name: "permissionName",
                placeholder: "请输入资源名称",
                rules: [{
                    required: true,
                    message: "请输入资源名称"
                }],
            },
            {
                type: FormItemType.SELECT,
                label: "父节点",
                name: "parentId",
                placeholder: "请输入父节点",
                rules: [{
                    required: true,
                    message: "请输入父节点"
                }],
                props: {
                    label: "permissionName",
                    value: "id"
                },
                sourceData: []
            },
            {
                type: FormItemType.INPUT,
                label: "资源链接",
                name: "permissionLink",
                placeholder: "请输入资源链接",
                rules: [{
                    required: true,
                    message: "请输入资源链接"
                }]
            },
            {
                type: FormItemType.INPUT,
                label: "资源图标",
                name: "permissionIcon",
                placeholder: "请输入资源图标"
            },
            {
                type: FormItemType.INPUT,
                label: "唯一标识",
                name: "permissionKey",
                placeholder: "请输入资源唯一标识"
            },
            {
                type: FormItemType.INPUT,
                label: "资源组件",
                name: "permissionComponent",
                placeholder: "请输入资源组件"
            },
            {
                type: FormItemType.RADIO,
                label: "展示方式",
                name: "permissionDisplayModel",
                props: {
                    label: "label",
                    value: "value"
                },
                sourceData: DisplaySlide,
            },
            {
                type: FormItemType.RADIO,
                label: "首页展示",
                name: "permissionIsHome",
                props: {
                    label: "label",
                    value: "value"
                },
                sourceData: CommonState,
            },
            {
                type: FormItemType.RADIO,
                label: "外链设置",
                name: "permissionIsOuter",
                props: {
                    label: "label",
                    value: "value"
                },
                sourceData: CommonState,
            },
            {
                type: FormItemType.RADIO,
                label: "授权展示",
                name: "permissionDisplayRuleWay",
                props: {
                    label: "label",
                    value: "value"
                },
                sourceData: DisplayRuleWay,
            },
            {
                type: FormItemType.RADIO,
                label: "侧边展示",
                name: "permissionIsDisplaySlide",
                props: {
                    label: "label",
                    value: "value"
                },
                sourceData: CommonState,
            },
            {
                type: FormItemType.RADIO,
                label: "顶部设置",
                name: "permissionIsTop",
                props: {
                    label: "label",
                    value: "value"
                },
                sourceData: CommonState,
            }, {
                type: FormItemType.NUMBER,
                label: "排序",
                name: "orderNum"
            }
        ]
    }, {
        label: "基本信息",
        grid: 3,
        fields: [
            {
                type: FormItemType.SELECT,
                label: "subKey",
                name: "subKey",
                placeholder: "请选择菜单栏父节点(刷新页面菜单展开)",
                props: {
                    label: "permissionName",
                    value: "permissionLink"
                },
                sourceData: []
            },
            {
                type: FormItemType.INPUT,
                label: "title",
                name: "title",
                placeholder: "请输入菜单标题"
            },
            {
                type: FormItemType.INPUT,
                label: "subTitle",
                name: "subTitle",
                placeholder: "请输入菜单描述"
            }
        ]
    }]
};

export default {
    columns: columns,
    searchFormSchema: searchFormSchema,
    editFormSchema: editFormSchema
}